package com.VitalFit.model.entity;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.VitalFit.model.enums.FitnessPlanTypeEnum;
import com.VitalFit.model.enums.OrderStateEnum;
import jakarta.persistence.*;
import lombok.Data;

import java.time.LocalDate;

@Entity
@Data
@Table(name = "fitness_plan", indexes = {
        @Index(name = "idx_expiration_date", columnList = "expirationDate")
})
public class FitnessPlan {

    @Id
    private Long id;

    private int durationMonths; // 有效期，以月计
    private LocalDate startDate; // 健身计划的开始日期
    private LocalDate expirationDate; // 健身计划的到期日期

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "customer_id")
    private Customer customer;

    @Enumerated(EnumType.STRING)
    private FitnessPlanTypeEnum planType;

    @Enumerated(EnumType.STRING)
    private OrderStateEnum orderStateEnum;


    public FitnessPlan() {
        // 使用 Hutool 的 Snowflake 生成 ID
        Snowflake snowflake = IdUtil.getSnowflake(1, 1);
        this.id = snowflake.nextId();
    }
}

